# -*- coding: utf-8 -*-
from flask import Flask, request, redirect, render_template
from flask_wtf import CSRFProtect
from flask_bootstrap import Bootstrap5
from controller.user import user
from controller.article import article
from controller.video import video
from controller.front import front

app = Flask(__name__, template_folder='templates')
app.secret_key = 'dev'
bootstrap = Bootstrap5(app)
# 设置为使用本地资源
app.config['BOOTSTRAP_SERVE_LOCAL'] = True 
# 设置默认按钮的样式和尺寸
app.config['BOOTSTRAP_BTN_STYLE'] = 'primary'
app.config['BOOTSTRAP_BTN_SIZE'] = 'sm'
# 设置表格默认的操作按钮图标
app.config['BOOTSTRAP_TABLE_VIEW_TITLE'] = 'Read'
app.config['BOOTSTRAP_TABLE_EDIT_TITLE'] = 'Update'
app.config['BOOTSTRAP_TABLE_DELETE_TITLE'] = 'Remove'
app.config['BOOTSTRAP_TABLE_NEW_TITLE'] = 'Create'
csrf = CSRFProtect(app)

app.register_blueprint(user)
app.register_blueprint(article)
app.register_blueprint(video)
app.register_blueprint(front)

@app.route('/')
def index():
    return redirect('/front/index')
# 后台首页
@app.route('/back/index')
def backIndex():
    return render_template('back/index.html')

@app.route('/login')
def login1():
    return render_template('user/login.html')

if __name__ == '__main__':
    # createDataBase('python1688')
    # tables = [User.__table__, Article.__table__, Video.__table__]
    # createTableByBase(tables=tables)
    app.run(debug=True, host='0.0.0.0')
